﻿using System;
using System.Linq;
using System.Configuration;

namespace OrbitOne.Elmah.Data
{
    ///<summary>
    /// Represents the ElmahDataProvider
    ///</summary>
    public class ElmahDataProvider
    {
        #region Singleton
      /*  private static ElmahDataProvider _instance;
        /// <summary>
        /// Gets the only instance of the ElmahDataProvider.
        /// </summary>
        public static ElmahDataProvider Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new ElmahDataProvider();
                }
                return _instance;
            }
        }
        /// <summary>
        /// Explicit constructor to mark type as beforefieldinit
        /// </summary>
        static ElmahDataProvider()
        {
        }*/
        #endregion

        #region Private members
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets the <code>IElmahContext</code>
        /// </summary>
        public ElmahDataContext Context { get; private set; }
        #endregion

        #region Constructor
        /// <summary>
        /// Creates a new ElmahDataProvider based on the configuration settings.
        /// </summary>
        public ElmahDataProvider()
        {
            Context = new ElmahDataContext(ConfigurationManager.ConnectionStrings["OrbitOne_ElmahConnectionString"].ConnectionString);
        }
        #endregion

        #region Public Methods
        /// <summary>
        /// Disposes the ElmahDataProvider
        /// </summary>
        public void Dispose()
        {
            Context.Dispose();
        }
        #endregion
    }
}